package service

import (
	"context"
	"webook/search/domain"
	"webook/search/repository"
)

type SyncService interface {
	InputUser(ctx context.Context, user domain.User) error
	InputArticle(ctx context.Context, art domain.Article) error
	InputAny(ctx context.Context, index, docID, data string) error
}

type syncService struct {
	userRepo repository.UserSearchRepository
	artRepo  repository.ArticleSearchRepository
	anyRepo  repository.AnySearchRepository
}

func NewSyncService(userRepo repository.UserSearchRepository, artRepo repository.ArticleSearchRepository,
	anyRepo repository.AnySearchRepository) SyncService {
	return &syncService{
		userRepo: userRepo,
		artRepo:  artRepo,
		anyRepo:  anyRepo,
	}
}

func (svc *syncService) InputUser(ctx context.Context, user domain.User) error {
	return svc.userRepo.InputUser(ctx, user)
}

func (svc *syncService) InputArticle(ctx context.Context, art domain.Article) error {
	return svc.artRepo.InputArticle(ctx, art)
}

func (svc *syncService) InputAny(ctx context.Context, index, docID, data string) error {
	return svc.anyRepo.InputAny(ctx, index, docID, data)
}
